package app.beit.fintrack.service.convert;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import app.beit.fintrack.bean.summary.SummaryTrackChartBean;
import app.beit.fintrack.entity.summary.SummaryTrackChart;

public class SummaryTrackChartConvert {

	/**
	 * Convert Entity To Bean
	 * 
	 * @param entity
	 * @return SummaryTrackChartBean
	 */
	public static SummaryTrackChartBean entityToBean(final SummaryTrackChart entity) {
		final SummaryTrackChartBean bean = new SummaryTrackChartBean();

		bean.setAmount(entity.getAmount() == null || entity.getAmount().toString().equalsIgnoreCase("") ? new BigDecimal("0") : entity.getAmount());
		bean.setRepNo(entity.getRepNo());
		bean.setTotal(entity.getTotal() == null || entity.getTotal().toString().equalsIgnoreCase("") ? new BigDecimal("0") : entity.getTotal());
		bean.setSumsServiceItem(entity.getSumsServiceItem() == null || entity.getSumsServiceItem().toString().equalsIgnoreCase("") ? new BigDecimal("0") : entity.getSumsServiceItem());
		bean.setNhsoAmount(entity.getNhsoAmount() == null || entity.getNhsoAmount().toString().equalsIgnoreCase("") ? new BigDecimal("0") : entity.getNhsoAmount());
		bean.setHmainAmount(entity.getHmainAmount() == null || entity.getHmainAmount().toString().equalsIgnoreCase("") ? new BigDecimal("0") : entity.getHmainAmount());
		bean.setOrfAmount(entity.getOrfAmount() == null || entity.getOrfAmount().toString().equalsIgnoreCase("") ? new BigDecimal("0") : entity.getOrfAmount());
		
		return bean;
	}

	/**
	 * Convert Bean to Entity
	 * 
	 * @param bean
	 * @return SummaryTrackChart
	 */
	public static SummaryTrackChart beanToEntity(final SummaryTrackChartBean bean){
		final SummaryTrackChart entity = new SummaryTrackChart();

		entity.setAmount(bean.getAmount());
		entity.setRepNo(bean.getRepNo());
		entity.setTotal(bean.getTotal());
		entity.setSumsServiceItem(bean.getSumsServiceItem());

		return entity;
	}

	/**
	 * Convert List Entity to List Bean
	 * 
	 * @param entities
	 * @return List SummaryTrackChartBean
	 */
	public static List<SummaryTrackChartBean> entityToBean(final List<SummaryTrackChart> entities){
		final List<SummaryTrackChartBean> beans = new ArrayList<SummaryTrackChartBean>();

		for (final SummaryTrackChart entity : entities) {
			beans.add(SummaryTrackChartConvert.entityToBean(entity));
		}

		return beans;
	}

	/**
	 * Convert List Bean to List Entity
	 * 
	 * @param beans
	 * @return List SummaryTrackChart
	 */
	public static List<SummaryTrackChart> beanToEntity(final List<SummaryTrackChartBean> beans){
		final List<SummaryTrackChart> entities = new ArrayList<SummaryTrackChart>();

		for (final SummaryTrackChartBean bean : beans) {
			entities.add(SummaryTrackChartConvert.beanToEntity(bean));
		}

		return entities;
	}

}
